package com.wutuo.wtservice.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.wtservice.provider.domain.WtType;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseWtTypeMapper extends GenericMapper<WtType, Long> {

    @Override @Delete({"delete from wt_type", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override
    @Insert({"insert into wt_type (", "name,", "type_image,", "type_describe,", "create_by,",
        "create_date,", "update_by,", "update_date,", "remarks,", "del_flag", " )values(",
        "#{name,jdbcType=VARCHAR},", "#{typeImage,jdbcType=VARCHAR},",
        "#{typeDescribe,jdbcType=VARCHAR},", "#{createBy,jdbcType=BIGINT},",
        "#{createDate,jdbcType=DATE},", "#{updateBy,jdbcType=BIGINT},",
        "#{updateDate,jdbcType=DATE},", "#{remarks,jdbcType=VARCHAR},",
        "#{delFlag,jdbcType=VARCHAR})"}) int insert(WtType record);

    @InsertProvider(type = BaseWtTypeSqlProvider.class, method = "insertSelective")
    int insertSelective(WtType record);

    @Override
    @Select({"select", "name,", "type_image,", "type_describe,", "create_by,", "create_date,",
        "update_by,", "update_date,", "remarks,", "del_flag", "from wt_type",
        "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
        @Result(column = "type_image", property = "typeImage", jdbcType = JdbcType.VARCHAR),
        @Result(column = "type_describe", property = "typeDescribe", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    WtType selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseWtTypeSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WtType record);

    @Override @Update({"update wt_type", "set ", "type_image = #{typeImage,jdbcType=VARCHAR},",
        "name = #{name,jdbcType=VARCHAR},", "type_describe = #{typeDescribe,jdbcType=VARCHAR},",
        "create_by = #{createBy,jdbcType=BIGINT},", "create_date = #{createDate,jdbcType=DATE},",
        "update_by = #{updateBy,jdbcType=BIGINT},", "update_date = #{updateDate,jdbcType=DATE},",
        "remarks = #{remarks,jdbcType=VARCHAR},", "del_flag = #{delFlag,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"}) int updateByPrimaryKey(WtType record);
}